package com.whu.waterworks.action;

import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.whu.waterworks.dto.GisWaterplantData;
import com.whu.waterworks.model.TWaterplantdata;
import com.whu.waterworks.service.WaterPlantDataService;
import com.whu.waterworks.service.WaterPlantService;

public class GisWaterplantDataAction extends ActionSupport{
	/**
	 * 
	 */
	private static final long serialVersionUID = -5436803187992999430L;
	private WaterPlantService waterPlantService;
	private WaterPlantDataService waterPlantDataService;
	private List<GisWaterplantData> list;
	private String codes;
	public String getWaterplantData() throws Exception {
		// TODO Auto-generated method stub
		list  = new ArrayList<>();
		String[] codeArray =codes.split(",");
		for(String code:codeArray)
		{
			TWaterplantdata waterplantdata = waterPlantDataService.getLastWaterPlantData(code.trim());
			if(waterplantdata!=null )
			{					
				GisWaterplantData dto = new GisWaterplantData();
				dto.setGongshuiliang(waterplantdata.getTotalSupplyFlow());
				dto.setYulv(waterplantdata.getChlorineOut());
				dto.setZhuodu(waterplantdata.getTurbidityOut());
				dto.setCode(code.trim());
				list.add(dto);
			}
		}
		return super.execute();
	}
	
	public String getCodes() {
		return codes;
	}

	public void setCodes(String codes) {
		this.codes = codes;
	}

	public WaterPlantService getWaterPlantService() {
		return waterPlantService;
	}
	public void setWaterPlantService(WaterPlantService waterPlantService) {
		this.waterPlantService = waterPlantService;
	}
	public WaterPlantDataService getWaterPlantDataService() {
		return waterPlantDataService;
	}
	public void setWaterPlantDataService(WaterPlantDataService waterPlantDataService) {
		this.waterPlantDataService = waterPlantDataService;
	}
	public List<GisWaterplantData> getList() {
		return list;
	}
	public void setList(List<GisWaterplantData> list) {
		this.list = list;
	}
	
}
